
import 'dart:async';

import 'package:flutter/services.dart';

const MethodChannel _kChannel = MethodChannel('com.ahj/WechatH5PayPlugin');
typedef Future<dynamic> EventHandler(Map<String, dynamic> event);
class WXPayUtils {

  void addEventHandler({
      EventHandler onReceiveNotification,
      EventHandler onOpenNotification,
      EventHandler onReceiveMessage,
      EventHandler onflushData,
    }) {
      _kChannel.setMethodCallHandler(_handleMethod);
    }
  /**
   * h5支付
   */
  static Future<String> wxH5Pay(String playUrl) async {
    Map<String, dynamic> map = Map();
    map["mwebUrl"] = playUrl;
   return await _kChannel.invokeMethod('WechatH5Pay', map);
  }



  Future<Null> _handleMethod(MethodCall call) async {
      switch (call.method) {
        case "aliPayResult":
          return Future.value(call.arguments);
       /* case "flushData":
          return _flushData("121r4");*/
        default:
          throw new UnsupportedError("Unrecognized Event");
      }
    }
}